{% extends "base.html" %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2"><i class="fas fa-user me-2"></i>个人信息</h1>
</div>

<div class="row">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header">
                <h5 class="card-title mb-0"><i class="fas fa-edit me-2"></i>编辑个人信息</h5>
            </div>
            <div class="card-body">
                {% with messages = get_flashed_messages() %}
                    {% if messages %}
                        {% for message in messages %}
                            <div class="alert alert-info alert-dismissible fade show" role="alert">
                                {{ message }}
                                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                            </div>
                        {% endfor %}
                    {% endif %}
                {% endwith %}

                <form method="POST" action="{{ url_for('update_profile') }}">
                    <div class="mb-3">
                        <label for="username" class="form-label">用户名</label>
                        <input type="text" class="form-control" id="username" value="{{ user.username }}" readonly>
                        <div class="form-text">用户名创建后不可修改</div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="email" class="form-label">邮箱</label>
                        <input type="email" class="form-control" id="email" name="email" value="{{ user.email or '' }}" placeholder="请输入邮箱地址">
                    </div>
                    
                    <hr>
                    
                    <h6 class="mb-3">修改密码</h6>
                    <div class="mb-3">
                        <label for="current_password" class="form-label">当前密码</label>
                        <input type="password" class="form-control" id="current_password" name="current_password" placeholder="请输入当前密码">
                    </div>
                    
                    <div class="mb-3">
                        <label for="new_password" class="form-label">新密码</label>
                        <input type="password" class="form-control" id="new_password" name="new_password" placeholder="请输入新密码（至少6位）">
                    </div>
                    
                    <button type="submit" class="btn btn-primary">
                        <i class="fas fa-save me-1"></i>保存更改
                    </button>
                </form>
            </div>
        </div>
    </div>
    
    <div class="col-md-4">
        <div class="card">
            <div class="card-header">
                <h5 class="card-title mb-0"><i class="fas fa-info-circle me-2"></i>账户信息</h5>
            </div>
            <div class="card-body">
                <div class="mb-3">
                    <strong>用户ID：</strong>
                    <span class="text-muted">{{ user.id }}</span>
                </div>
                <div class="mb-3">
                    <strong>注册时间：</strong>
                    <span class="text-muted">{{ user.created_at.strftime('%Y-%m-%d %H:%M:%S') }}</span>
                </div>
                <div class="mb-3">
                    <strong>最后登录：</strong>
                    <span class="text-muted">
                        {% if user.last_login %}
                            {{ user.last_login.strftime('%Y-%m-%d %H:%M:%S') }}
                        {% else %}
                            从未登录
                        {% endif %}
                    </span>
                </div>
                <div class="mb-3">
                    <strong>账户状态：</strong>
                    {% if user.is_active %}
                        <span class="badge bg-success">活跃</span>
                    {% else %}
                        <span class="badge bg-danger">禁用</span>
                    {% endif %}
                </div>
            </div>
        </div>
        
        <div class="card mt-4">
            <div class="card-body text-center">
                <i class="fas fa-user-circle fa-4x text-primary mb-3"></i>
                <h5>{{ user.username }}</h5>
                <p class="text-muted">BOSS招聘数据分析系统用户</p>
                <a href="{{ url_for('dashboard') }}" class="btn btn-outline-primary btn-sm">
                    <i class="fas fa-tachometer-alt me-1"></i>返回控制台
                </a>
            </div>
        </div>
    </div>
</div>
{% endblock %}